package cn.wx.scholar.neo4j.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import cn.wx.common.persistence.base.BaseController;
import cn.wx.common.persistence.web.ResponseData;
import cn.wx.scholar.neo4j.entity.qo.ExpertQ;
import cn.wx.scholar.neo4j.service.ExpertService;

/**
 * @description : Expert 控制器 ---------------------------------
 * @author
 * @since 2018-07-12
 */
@RestController
@RequestMapping("/sholar/expert")
public class ExpertController extends BaseController {

	@Autowired
	private ExpertService expertService;

	/**
	 * 根据条件查询专家数
	 */
	@RequestMapping(value = "/loadExpertsOrgCount", method = RequestMethod.POST)
	public ResponseData loadExpertsOrgCount(ExpertQ expertQ) {
		return success(expertService.loadExpertsOrgCount(expertQ));
	}
	
	/**
	 * 新的聚类接口
	 * @param fos
	 * @return
	 */
	@RequestMapping(value = "/expertUnwind2", method = RequestMethod.POST)
	public ResponseData expertUnwind2(@RequestParam(value = "fos") String fos) {
		return success(expertService.expertUnwind2(fos));
	}
	
	
	@RequestMapping(value = "/getExpertDetail", method = RequestMethod.POST)
	public ResponseData getExpertDetailById(@RequestParam(value = "id") Long id) {
		return success(expertService.findById(id));
	}

	@RequestMapping(value = "/getIndexNum", method = RequestMethod.POST)
	public ResponseData getIndexNum(ExpertQ expertQ) {
		return success(expertService.getIndexNum(expertQ));
	}

	/**
	 * 根据专家AID，专家B名字或者机构名称和查询类型来检索最短路径
	 * 
	 * @param expertQ
	 * @return
	 */
	@RequestMapping(value = "/getRelationForExpertOrOrg", method = RequestMethod.POST)
	public ResponseData getRelationForExpertOrOrg(@RequestParam(value = "type") String type,
			@RequestParam(value = "expert1Id") Long expert1Id, @RequestParam(value = "expert2Id") Long expert2Id) {
		return success(expertService.getRelationForExpertOrOrg(type, expert1Id, expert2Id));
	}

	/**
	 * 根据搜索条件获取language数据
	 * 
	 * @param expertQ
	 * @return
	 */
	@RequestMapping(value = "/getLanguage", method = RequestMethod.POST)
	public ResponseData getLanguageInfo(ExpertQ expertQ) {
		return success(expertService.getLanguageInfo(expertQ));
	}

	/**
	 * 根据搜索条件获取country数据
	 * 
	 * @param expertQ
	 * @return
	 */
	@RequestMapping(value = "/getCountry", method = RequestMethod.POST)
	public ResponseData getCountryInfo(ExpertQ expertQ) {
		return success(expertService.getCountryInfo(expertQ));
	}

	/**
	 * 根据专家Id查询关联专家：论文/图书
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/getRelateExpert", method = RequestMethod.POST)
	public ResponseData getRelateExpert(@RequestParam(value = "id") Long id) {
		return success(expertService.getRelateExpert(id));
	}

	/**
	 * 根据专家Id查询关联专家：论文/图书1
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/getRelateExpert1", method = RequestMethod.POST)
	public ResponseData getRelateExpert1(@RequestParam(value = "id") Long id) {
		return success(expertService.getRelateExpert1(id));
	}
	
	/**
	 * neo4j session测试
	 */
	@RequestMapping(value = "/loadExperts", method = RequestMethod.POST)
	public ResponseData loadExperts(ExpertQ expertQ) {
		return success(expertService.loadExperts(expertQ));
	}
	
	@RequestMapping(value = "/getExpertByName", method = RequestMethod.POST)
	public ResponseData getExpertByName(@RequestParam(value = "name")String name) {
		return success(expertService.getExpertByName(name));
	}

	/**
	 * 根据输入框的搜索条件 二级页面合作专家查询
	 */
	@RequestMapping(value = "/getRelateExpertParam", method = RequestMethod.POST)
	public ResponseData getRelateExpertParam(ExpertQ expertQ) {
		return success(expertService.getRelateExpertParam(expertQ));
	}

	/**
	 * 三级页面专家对领域的论文数查询
	 */
	@RequestMapping(value = "/expertFosQz", method = RequestMethod.POST)
	public ResponseData expertFosQz(@RequestParam(value = "foses") List<String> foses) {
		return success(expertService.expertFosQz(foses));
	}

	/**
	 * 根据机构查询专家
	 */
	@RequestMapping(value = "/getExpertByOrg", method = RequestMethod.POST)
	public ResponseData getExpertByOrg(@RequestParam(value = "orgId") Long orgId) {
		return success(expertService.getExpertByOrg(orgId));
	}

	/**
	 * 根据机构和领域查询专家
	 */
	@RequestMapping(value = "/getExpertByOrgAndFos", method = RequestMethod.POST)
	public ResponseData getExpertByOrgAndFos(@RequestParam(value = "orgId") Long orgId,
			@RequestParam(value = "fosName") String fosName) {
		return success(expertService.getExpertByOrgAndFos(orgId, fosName));
	}

	/**
	 * 机构下一起合作过的专家
	 * 
	 * @param orgName
	 * @param nodesCount数量限制
	 * @return
	 */
	@RequestMapping(value = "/getRelateExpertByOrg", method = RequestMethod.POST)
	public ResponseData getRelateExpertByOrg(@RequestParam(value = "orgId") Long orgId,
			@RequestParam(value = "nodesCount") Integer nodesCount) {
		return success(expertService.getRelateExpertByOrg(orgId, nodesCount));
	}

	/**
	 * 确认人数最多的那个领域
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/sureFosHasMaxExperts", method = RequestMethod.POST)
	public ResponseData sureFosHasMaxExperts(@RequestParam(value = "fosName") String fosName) {
		return success(expertService.sureFosHasMaxExperts(fosName));
	}
	
	/**
	 * 查询n-index趋势图
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/queryNindex", method = RequestMethod.POST)
	public ResponseData queryNindex(ExpertQ expertQ) {
		return success(expertService.queryNindex(expertQ));
	}
	
	/**
	 * 查询四个index趋势
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/queryIndexTrend", method = RequestMethod.POST)
	public ResponseData queryIndexTrend(@RequestParam(value = "fId") Long fId) {
		return success(expertService.queryIndexTrend(fId));
	}
	
	/**
	 * 查询indexValue值和雷达值和百分比值
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/queryIndexValueAndRander", method = RequestMethod.POST)
	public ResponseData queryIndexValueAndRander(@RequestParam(value = "id") Long id) {
		return success(expertService.queryIndexValueAndRander(id));
	}
	
	/**
	 * 查询查询5年 10 年的写论文的专家数
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/get5Or10ExpertPapers", method = RequestMethod.POST)
	public ResponseData get5Or10ExpertPapers(ExpertQ expertQ) {
		return success(expertService.get5Or10ExpertPapers(expertQ));
	}
	
	/**
	 * 查询创新图
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/queryCindex", method = RequestMethod.POST)
	public ResponseData queryCindex(@RequestParam(value = "fId") Long fId) {
		return success(expertService.queryCindex(fId));
	}

	/**
	 * 专家被查看功能
	 */
	@RequestMapping(value = "/addViewCou", method = RequestMethod.POST)
	public ResponseData addViewCou(@RequestParam(value = "fId") Long fId) {
		expertService.addViewCou(fId);
		return success();
	}
	
	
}
